package com.dhl.deliver.service.impl;

import com.dhl.deliver.entity.User;
import com.dhl.deliver.exception.MyException;
import com.dhl.deliver.mapper.UserMapper;
import com.dhl.deliver.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dhl.deliver.utils.ResultEnum;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dhl
 * @since 2020-07-15
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public String getCurrentUserId(HttpServletRequest request) {
        final Object id = request.getSession().getAttribute("id");
        if (id==null)
            throw new MyException(ResultEnum.ERROR.getCode(),"用户未登录");
        return (String)id;
    }
}
